package com.lmx.repoDomain.tmodel;

import io.katharsis.resource.annotations.JsonApiIncludeByDefault;
import io.katharsis.resource.annotations.JsonApiResource;
import io.katharsis.resource.annotations.JsonApiToOne;
import javax.persistence.*;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

/**
 * 用餐计划与食物关联表
 */
@Entity
@Table(name = "rel_food_plan")
@JsonApiResource(type = "relfoodplan")
public class RelFoodPlan extends BaseEntity {
	private Food food;
	private CustomerFoodPlan plan;
	private String remark;// 备注

	@JsonApiToOne
	//@JsonApiIncludeByDefault
	@Fetch(FetchMode.JOIN)
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "plan_id", foreignKey = @ForeignKey(name = "null"))
	public CustomerFoodPlan getPlan() {
		return plan;
	}

	public void setPlan(CustomerFoodPlan plan) {
		this.plan = plan;
	}

	@JsonApiToOne
	@JsonApiIncludeByDefault
	@Fetch(FetchMode.JOIN)
	@OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "food_id", foreignKey = @ForeignKey(name = "null"))
	public Food getFood() {
		return food;
	}

	public void setFood(Food food) {
		this.food = food;
	}

	
	@Column(name = "remark")
	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}
}